#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["nuget.config", "."]
COPY ["src/Leo.Core.Gateway.HttpApi.Host/Leo.Core.Gateway.HttpApi.Host.csproj", "src/Leo.Core.Gateway.HttpApi.Host/"]
COPY ["src/Leo.Core.Gateway.Application/Leo.Core.Gateway.Application.csproj", "src/Leo.Core.Gateway.Application/"]
COPY ["src/Leo.Core.Gateway.Application.Contracts/Leo.Core.Gateway.Application.Contracts.csproj", "src/Leo.Core.Gateway.Application.Contracts/"]
COPY ["src/Leo.Core.Gateway.Domain.Shared/Leo.Core.Gateway.Domain.Shared.csproj", "src/Leo.Core.Gateway.Domain.Shared/"]
COPY ["src/Leo.Core.Gateway.Domain/Leo.Core.Gateway.Domain.csproj", "src/Leo.Core.Gateway.Domain/"]
COPY ["src/Leo.Core.Gateway.EntityFrameworkCore/Leo.Core.Gateway.EntityFrameworkCore.csproj", "src/Leo.Core.Gateway.EntityFrameworkCore/"]
COPY ["src/Leo.Core.Gateway.HttpApi/Leo.Core.Gateway.HttpApi.csproj", "src/Leo.Core.Gateway.HttpApi/"]
RUN dotnet restore "src/Leo.Core.Gateway.HttpApi.Host/Leo.Core.Gateway.HttpApi.Host.csproj"
COPY . .
WORKDIR "/src/src/Leo.Core.Gateway.HttpApi.Host"
RUN dotnet build "Leo.Core.Gateway.HttpApi.Host.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Leo.Core.Gateway.HttpApi.Host.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Leo.Core.Gateway.HttpApi.Host.dll"]